from gui import gui
from gui . tests . create_widget_test_assistant import gui_create_widget_test_assistant

class application_window_fake :
    pass

class image_fake :
    def __init__ ( self , master , image ) :
        self . _args = [ master , image ]

class photo_image_fake :
    _deleted_count = 0
    def __init__ ( self , data ) :
        self . _data = data
    def __del__ ( self ) :
        photo_image_fake . _deleted_count += 1

class tkinter_fake :
    def __init__ ( self ) :
        self . _application_windows = [ ]
        self . _image_collection = [ ]
        self . _photo_images = [ ]
    def Tk ( self ) :
        window = application_window_fake ( )
        self . _application_windows += [ window ]
        return window
    def Label ( self , master , _fake_arg = None , text = None , borderwidth = None , relief = None , anchor = None , textvariable = None , image = None ) :
        image_widget = image_fake ( master , image )
        self . _image_collection += [ image_widget ]
        return image_widget
    def PhotoImage ( self , _fake_arg = None , data = None ) :
        photo_image = photo_image_fake ( data )
        self . _photo_images += [ photo_image ]
        return photo_image

class mediator_fake :
    def __init__ ( self ) :
        self . _gui_create_application_window_reply = None
        self . _gui_create_image_reply = None
    def gui_create_application_window_reply ( self , window ) :
        self . _gui_create_application_window_reply = window
    def gui_create_image_reply ( self , image ) :
        self . _gui_create_image_reply = image 

class gui_image_tests :
    'gui_image'
    def __init__ ( self , test ) :
        self . _assistant = gui_create_widget_test_assistant ( test )
        self . _test = test
        self . _tkinter = tkinter_fake ( )
        self . _mediator = mediator_fake ( )
        self . _gui = gui ( mediator = self . _mediator , tkinter = self . _tkinter , tkfont = None , scheduler = None )
        photo_image_fake . _deleted_count = 0
    def test_gui_create_image ( self ) :
        self . _assistant . check_gui_create_arbitrary_element ( 'image' , 'my image' )
    def test_gui_create_image_photo_image ( self ) :
        self . _gui . gui_create_application_window_request ( )
        window = self . _mediator . _gui_create_application_window_reply
        self . _gui . gui_create_image_request ( window , 'my image' )
        self . _test . assume_equal ( self . _tkinter . _photo_images [ 0 ] . _data , 'my image' )
    def test_gui_create_image_args ( self ) :
        self . _gui . gui_create_application_window_request ( )
        window = self . _mediator . _gui_create_application_window_reply
        self . _gui . gui_create_image_request ( window , 'my image' )
        self . _test . assume_equal ( self . _tkinter . _image_collection [ 0 ] . _args ,
            [ self . _tkinter . _application_windows [ 0 ]
            , self . _tkinter . _photo_images [ 0 ]
            ] )
    def test_gui_create_image_photo_image_persistance ( self ) :
        self . _gui . gui_create_application_window_request ( )
        window = self . _mediator . _gui_create_application_window_reply
        self . _gui . gui_create_image_request ( window , 'my image' )
        image = self . _mediator . _gui_create_image_reply
        self . _tkinter . _photo_images = [ ]
        self . _tkinter . _image_collection = [ ]
        image . _args = [ ]
        self . _test . assume_equal ( photo_image_fake . _deleted_count , 0 )        
    def test_gui_create_image_photo_image_destruction ( self ) :
        self . _gui . gui_create_application_window_request ( )
        window = self . _mediator . _gui_create_application_window_reply
        self . _gui . gui_create_image_request ( window , 'my image' )
        image = self . _mediator . _gui_create_image_reply
        self . _tkinter . _photo_images = [ ]
        self . _tkinter . _image_collection = [ ]
        self . _mediator . _gui_create_image_reply = None
        image . _args = [ ]
        del image
        self . _test . assume_equal ( photo_image_fake . _deleted_count , 1 )
    def test_gui_create_image_persistance ( self ) :
        self . _assistant . check_gui_create_arbitrary_element_persistance ( 'image' , 'my image' )
    def test_gui_create_image_destruction ( self ) :
        self . _assistant . check_gui_create_arbitrary_element_destruction ( 'image' , 'my image' )
    def test_gui_create_image_encapsulation ( self ) :
        self . _assistant . check_gui_create_arbitrary_element_encapsulation ( 'image' , 'my image' )
    def test_gui_create_image_child ( self ) :
        self . _assistant . check_gui_create_arbitrary_element_child ( 'image' , 'my image' )
